import java.util.Arrays;
import java.util.Comparator;

/**
 * User: 86156
 * Date: 2023-04-16
 * Time: 15:32
 */
public class Lambda1 {
    public static void main(String[] args) {
        Integer [] arr = {2,3,7,8,1,5,9};

        // 匿名内部类
        Arrays.sort(arr, new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o1-o2;
            }
        });

        // Lambda 表达式
        Arrays.sort(arr, (Integer o1, Integer o2)-> {
                return o1-o2;
            }
        );


        System.out.println(Arrays.toString(arr));
    }
}
